package zhang.automobileservice;

import android.graphics.Color;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;

import java.util.ArrayList;

import adapter.FirstpageAdapter;
import fragment.DiscoverFragment;
import fragment.FirstpageFragment;
import fragment.MyselfFragment;


/**
 * Created by Administrator on 2016/7/18.
 */
public class FirstpageActivity extends FarterActivity {
    private TabLayout tb_firstpage;
    private ArrayList<Fragment> fragments;
    private ViewPager vp_firstpage;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_firstpage);
        initView();
        initData();

    }

    private void initData() {
        fragments = new ArrayList<>();
        fragments.add(new FirstpageFragment());
        fragments.add(new DiscoverFragment());
        fragments.add(new MyselfFragment());
        vp_firstpage.setAdapter(new FirstpageAdapter(getSupportFragmentManager(),this,fragments));
        tb_firstpage.setupWithViewPager(vp_firstpage);
        tb_firstpage.setTabTextColors(Color.parseColor("#bbbbbb"), Color.parseColor("#0f97ee"));
        tb_firstpage.setSelectedTabIndicatorHeight(0);
        tb_firstpage.getTabAt(0).setText("首页").setIcon(R.drawable.bottom_icon01);
        tb_firstpage.getTabAt(1).setText("发现").setIcon(R.drawable.bottom_icon02);
        tb_firstpage.getTabAt(2).setText("我的").setIcon(R.drawable.bottom_icon03);
    }

    private void initView() {
        tb_firstpage = (TabLayout) findViewById(R.id.tb_firstpage);
        vp_firstpage = (ViewPager) findViewById(R.id.vp_firstpage);
    }
}
